<div class="list-group" id="user_product_list">
    <div class="list-group-item">
        <?php foreach ($products as $product):
            echo '<div class="item">';
            $image=$product['Product']['picture1'];
            if(empty($image)){
                $image = 'default_product.png';
                $resizedFile = 'uploads/'.$image;
            }else {
               $resizedFile = 'uploads/images_resize/'.$image;
            }
            //echo '<a href="posts/view/'.$product['Product']['id'].'"><img style="width: 100px; "src="'.$this->webroot.$resizedFile.'"/></a>';
            echo $this->Html->link($this->Html->image($resizedFile), array('controller'=>'posts', 'action' => 'view', $product['Product']['id']), array('escape' => false));
            if (strlen($product['Product']['title']) > 30) {
                echo '<span class="pro-title">'.$this->Html->link(substr($product['Product']['title'], 0, 30).'...', array('controller' => 'posts', 'action' => 'view', $product['Product']['id'])).'</span>';
            }else {
                echo '<span class="pro-title">'.$this->Html->link($product['Product']['title'], array('controller' => 'posts', 'action' => 'view', $product['Product']['id'])).'</span>';
            }
            echo '<span id="pro-price">$'.$product['Product']['price'].'<i class="'.$product['Product']['status'].'"></i></span>';
            echo '<span id="modified_date">'.$product['Product']['modified_date'].'</span>';
            if($product['Product']['name']) {echo '<span id="auth">'.$product['Product']['name'].'</span>';}
            if($product['Location']['name']) {echo '<span id="address">'.$product['Location']['name'].'</span>';}
            echo '<span id="phone">'.$product['Product']['phone'].'</span><br>';
            if (strlen($product['Product']['description']) > 150) {
                echo '<span id="dec">'.substr($product['Product']['description'], 0, 150).'...'.'</span>';
            }else {
                echo '<span id="dec">'.$product['Product']['description'].'</span>';
            }
            
            echo '<div class="total-view">';
            if($product['Product']['view']) {
                echo '<span class="total-product">View:'.$product['Product']['view'].'</span>';
            }else {
                echo '<span class="total-product">View: 0</span>';
            }
            $i = 0;
            for($a=1; $a<=4; $a++){
                $picture = "picture$a";
                if($product['Product'][$picture]){
                    $i++;
                }
            }
            echo '<span class="total-image">'.$i.'</span>';

            echo '<span class="total-comment">'.count($product['Comment']).'</span>';
//            $total = 0;
//            foreach ($counttoday as $today) {
//                if($product['Product']['id'] == $today['Statistic']['product_id']) {
//                    $total = $today['Statistic']['count'];
//                }
//            }
//            echo '<apan class="total-today"> Today viewed:'.$total.'</span>';
            echo '</div>';
            
            echo '<div class="button-action">';
                echo $this->Html->link(__('View'), array('controller' => 'posts', 'action' => 'view', $product['Product']['id']));
                echo $this->Html->link(__('Edit'), array('controller' => 'products', 'action' => 'edit', $product['Product']['id']));
                echo $this->Form->postLink(__('Delete'), array('controller' => 'posts', 'action' => 'delete', $product['Product']['id']), null, __('Are you sure you want to delete # %s?', $product['Product']['id']));
            echo '</div>';
            echo '<div class="clearfix"></div></div>';
        endforeach;?>
    </div>
</div>
            